Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve state and config changes in ec2_instance #550

Closed

Conversation

jillr
Copy link
Collaborator

@jillr jillr commented Apr 19, 2021

SUMMARY

Fixes: #16
This patch ensures that when changing state and/or supported parameters for
an instance, changes are applied regardless of the starting or desired state
of the instance.

This patch depends on Python3 and SHOULD NOT be merged until this module is
migrated to the amazon.aws collection and collection version 2.x.

We're ready to start working on 2.x now, so this can be merged.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ec2_instance

ADDITIONAL INFORMATION

This PR is being opened here WIP to allow the community time to review prior to the module migration to amazon.aws and Python bump to 3-only. A new PR will be opened there and referenced to any reviews here.
On further thought, it'll probably be easier to merge this here before migrating the module.
Except that I haven't removed the py2.7 tests from CI yet so I'm going to stop changing my mind and get ready to migrate the module!

I'm undecided if I'm happy about adding another integration test suite or if it would make more sense to combine these with the termination_protection tests. Review feedback desired.

DO NOT MERGE!!!
Fixes: community.aws/issues/16
This patch ensures that when changing state and/or supported parameters for
an instance, changes are applied regardless of the starting or desired state
of the instance.

This patch depends on Python3 and SHOULD NOT be merged until this module is
migrated to the amazon.aws collection and collection version 2.x.
@jillr jillr force-pushed the ec2_instance_state_handling branch from 585e5e9 to b4284d8 Compare April 19, 2021 18:09
@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review integration tests/integration module module needs_triage plugins plugin (any type) python3 tests tests labels Apr 19, 2021
@jillr jillr requested a review from tremble April 20, 2021 18:37
Copy link
Contributor

@briantist briantist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks really good to me, thank you for working on this! I have a lot on my plate right now and haven't had a chance to test it. Do tag me in the final version in the other collection!

Comment on lines +1466 to +1469
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-reboot.html
# The Ansible behaviour of issuing a stop/start has a minor impact on user billing
# This will need to be changelogged if we ever change to ec2.reboot_instance
_changed, _failed, _instances, _failure_reason = change_instance_state(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be interesting if this behavior changed because stopping and starting an instance gives new underlying hardware, but a reboot call doesn't. That's an important distinction when there are hardware issues on the instance (if you run long running instances like I do, this is quite a common occurrence).

I hadn't realized that this is what the module did so in playbooks I have for recovering, I do actually call the module twice, once to stop it and once to start. I wonder if anyone has settled on using using the restarted/rebooted statuses in Ansible to recover, only to find that it won't work anymore if this changes. Probably a niche thing...

But it does make me think.. a dedicated integrated "stop then start" mode (what restarted actually does now) would be useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut inclination was to change this to actually call `reboot' since it's not really doing what it advertises right now, and we'll have a narrow window before 2.0 where we can make non-backwards-compatible changes. But I don't want to overload this PR with too many changes.

Maybe @tremble can weigh in if it would be useful to make this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right, if it advertises reboot and a reboot call is available, that's what should be called. I'm only mentioning a case (albeit one that might be rare) where that change could be breaking. And that another option that explicitly does what the current behavior is might have uses. The new option value should be introduced before changing the behavior imo so that there's an overlap where people could make forward-compatible changes if they wanted to keep that behavior.

But I dunno maybe that's all overthinking.

(I also agree it's not really related to this PR)

Comment on lines +1614 to +1615
# TODO: this breaks check_mode, because change_instance_state handles checkmode but not ensure
# because ensure passes off to change...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's scary, I hope check mode will work properly before the final version 🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one might be a lingering comment from an earlier stage of the work-in-progress actually, I'll test to confirm - thanks for catching that!

@jillr jillr changed the title [WIP, DNM] Improve state and config changes in ec2_instance Improve state and config changes in ec2_instance May 3, 2021
@jillr jillr closed this May 3, 2021
@tremble
Copy link
Contributor

tremble commented May 4, 2021

in case anyone else wonders why this has been closed. ec2_instance is being migrated to amazon.aws

@jillr jillr deleted the ec2_instance_state_handling branch July 2, 2021 22:47
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request May 25, 2022
…stance (ansible-collections#551)

ec2_ami - Tag the image on creation when creating an image from an instance

SUMMARY
Tagging an instance during creation avoids the need to make an additional "tag" call on an untagged resource.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ec2_ami
ADDITIONAL INFORMATION
fixes: ansible-collections#550

Reviewed-by: Andy Thompson <None>
Reviewed-by: Mark Chappell <None>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug community_review integration tests/integration module module needs_triage plugins plugin (any type) python3 tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ec2_instance ignores some/all options depending on state option value and current actual state
4 participants